import { MessageReactive, MessageType } from 'naive-ui'
import { useTheme } from '@/store/modules/theme'
import { darkMode as darkModeMenu } from '~/types/theme'
import { alpha } from '@/utils/theme/setTheme'

//获取icon颜色
export function getIconColor() {
  const theme = useTheme()
  return computed(() =>
    theme.darkMode === darkModeMenu.DARK ? '#fff' : '#333'
  )
}

//获取icon相反主题的颜色
export function getIconReverseColor() {
  const theme = useTheme()
  return computed(() =>
    theme.darkMode === darkModeMenu.DARK ? '#333' : '#fff'
  )
}

/**
 * @type 'info' | 'success' | 'warning' | 'error' | 'loading' | 'default'
 * @msg  string
 */
export function useMsg(type: MessageType, msg: string) {
  let messageReactive: MessageReactive | null = null
  messageReactive = window['$message'][type](msg, {
    closable: true,
    duration: 5000
  })
  return messageReactive
}

//获取激活模块的背景色
export function getActivateColor() {
  const theme = useTheme()
  return {
    alphaColor: computed(() =>
      theme.darkMode === darkModeMenu.DARK
        ? alpha(theme.primary, 0.2)
        : alpha(theme.primary, 0.1)
    ),
    color: computed(() => theme.primary)
  }
}
